package com.yc.yyds.servlet;

import com.yc.yyds.Bean.Result;
import com.yc.yyds.biz.BizException;
import com.yc.yyds.biz.IndentBiz;
import com.yc.yyds.util.ToJsonUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "IndentQueryServlet", value = "/IndentQueryServlet.s")
public class IndentQueryServlet extends HttpServlet {
    IndentBiz biz = new IndentBiz();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String userid = request.getParameter("userid");
        Result result;
        try {
            final List<Map<String, Object>> data = biz.query(userid);
            result = new Result(1,"查询成功！",data);
            ToJsonUtil.toJson(response,result);
        } catch (BizException e) {
            e.printStackTrace();
            result = new Result(0,e.getMessage(),null);
            ToJsonUtil.toJson(response,result);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
